package com.sch.wanandroid.adapter

import android.view.View
import android.widget.ImageView
import androidx.core.text.HtmlCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.sch.wanandroid.R
import com.sch.wanandroid.entity.ArticleBean

/**
 * Created by Sch.
 * Date: 2020/12/14
 * description:
 */
class MyArticleAdapter : BaseQuickAdapter<ArticleBean, BaseViewHolder>(R.layout.item_article) {

    override fun convert(holder: BaseViewHolder, item: ArticleBean) {
        if (item.author.isEmpty()) {
            holder.setText(R.id.tvAuthor, item.shareUser)
        } else {
            holder.setText(R.id.tvAuthor, item.author)
        }
        holder.setText(R.id.tvTag, if (item.type == 1) "置顶  " else "")
        holder.setText(
            R.id.tvTitle,
            HtmlCompat.fromHtml(item.title, HtmlCompat.FROM_HTML_MODE_LEGACY)
        )
        holder.setText(R.id.tvDate, item.niceDate)
        holder.setText(R.id.tvChapterName, item.superChapterName)
        holder.getView<ImageView>(R.id.ivCollect).visibility = View.GONE
    }
}